package book;

/**
 * 具体的书本类
 */
public class Book {
    //书籍名称
    private String name;
    //作者
    private String author;
    //价格
    private double price;
    //书籍类型
    private String type;
    //借阅状态,默认为false
    private boolean isBorrowed;

    public Book(String name, String author, double price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    /**
     *具体信息的获取和设置方法
     */

    public void setPrice(double price) {
        this.price = price;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }

    public String getName() {
        return name;
    }

    public String getAuthor() {
        return author;
    }

    public double getPrice() {
        return price;
    }

    public String getType() {
        return type;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    @Override
    public String toString() {
        String flag = "否";
        if(isBorrowed)
            flag = "是";
        return  '[' +
                "书名：" + name + ' ' +
                "作者：" + author + ' ' +
                "价格：" + price + ' ' +
                "类型：" + type + ' ' +
                "是否借出：" + flag +
                ']';
    }
}
